草庐IT

Android PreferenceActivity 和对话框 fragment

全部标签

android - 停止 dpad 焦点超出 android 中的当前 fragment

我当前的应用需要使用方向键Remote进行控制。使用焦点/选择,最近邻居的自动计算按预期工作,但我想限制上、下、左、右移动仅发生在包含焦点View的当前fragment中,并在之前取消焦点更改它移动到另一个fragment。我在选择View时以编程方式将焦点更改为新fragment。这可能吗?我只能假设onFocusChange()事件允许我检查新焦点是否在fragment之外并返回但这里没有运气...... 最佳答案 简而言之,您可以在包含fragment的容器上调用setDescendantFocusability(ViewGr

android - ViewPager 在屏幕旋转时保留旧 fragment

我正在使用ViewPager和FragmentStatePagerAdapter来显示fragment。最初有2个fragment添加Fragment1和Fragment2,第三个fragmentFragment3在收到服务器响应后添加到第二个位置。所以在添加所有页面之后,这应该是ViewPager中的fragment序列-->Fragment1、Fragment3、Fragment2。问题是在添加Fragment1和Fragment3之后,如果我多次旋转屏幕,应用程序在添加第3个fragment之前调用服务器,然后在添加第3个fragment后,它仍然显示第2个位置的Fragment

android - 调用 findViewById() 获取 fragment View 时出现 NullPointerException

我正在尝试设置一个FragmentStatePagerAdapter以在我的一个fragment上创建一个类似于thisexample的可滚动选项卡界面.在我的Activity的onCreate中:@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.base);setVersionString();setupActionBar();setupNavigationDrawer();setupFragments();}

android - 为什么 findFragmentById 返回调用替换 Fragment Layout 之前的旧 fragment ?

为什么在将fragment从第一个(pageNews)更改为第二个(pageViewFromWeb)后,“findFragmentById”返回对第一个(pageNews)fragment的引用?布局:代码:fTrans=getSupportFragmentManager().beginTransaction();fTrans.add(R.id.frgmCont,pageNews);........publicvoidselectNews(Stringnews_id){//Toast.makeText(this,news_id,Toast.LENGTH_SHORT).show();fT

android - 如果 "display:none",文件选择器对话框不会在 android webview 中打开

开发者早上好嗯,我做了一个androidwebview应用程序,我遇到了一个小问题,我搜索了很多但找不到任何有效的解决方案。好的。问题是。我有这样的php/Html代码注意style="display:none;"我正在从div的onClick调用输入字段的onclick事件像这样通过JqueryClickheretoaddProfilePicture200px/200px这是我的java脚本openFileDialog()函数functionopenFileDialog(test){$("#banner_image").click();console.log("Test");}它没有

android - 如何将光标从android Activity 发送到 fragment

实际上我知道如何将额外的值从Activity发送到fragment,但我需要将联系人游标发送到fragment,然后我将该游标传递到游标适配器并在ListView中显示数据。 最佳答案 有多种方法可以完成您想要做的事情。只有其中一些要求您在创建fragment之前拥有Cursor。您可以创建一个方法来创建fragment并传入光标:publicclassYourFragmentextendsFragment{privateCursormCursor;publicstaticYourFragmentcreateYourFragment

android - 将 Activity 中的 Arraylist 传递给 Fragment

我有MyClass实现Parcelable。并有2个fragment。在MainActivity(onCreate)中我有代码:ArrayListdata=newArrayList();............Bundleextras1=newBundle();extras1.putParcelableArrayList("arraylist",data);Tab1Fragmentfg=newTab1Fragment();fg.setArguments(extras1);在Fragment(onCreateView)中:Bundleextras=getArguments();ListV

Android 对话框 - 自定义背景而不是变暗或模糊

我已经创建了自己的自定义对话框,它工作正常,但我想将变暗的背景更改为自定义图案(例如图像文件或xml形状)。我怎样才能做到这一点?请注意,我不想改变调光的强度,但我只想将这种调光替换为一种模式 最佳答案 我找到了解决这个问题的方法,我从@vipulmittal的回答中得出这个,我应该将对话框主题设置如下:falsetrue@android:color/transparent有了这个主题,我的对话将是:全屏因为windowIsFloating设置为false周围区域完全透明因为windowBackground设置为@android:c

android - 关闭对话框后如何刷新listView?

我创建了一个打开对话框的布局,进入对话框后,用户选择确定/取消。我想刷新listView重新查询数据这是我打开对话框的布局:button.setOnClickListener(newOnClickListener(){publicvoidonClick(Viewarg0){IntentmyIntent=newIntent(SchoolActivity.this,InsertSchool.class);update();startActivity(myIntent);updateList();}});update();cursor.requery();String[]from=newSt

android - 带有自定义 ListView 的自定义警报对话框

我需要创建一个带有单一选择的自定义警报对话框。但是项目有自己的布局:[VIEW(justcolor)_______TEXT_______RADIOBUTTON]我已经为ListView、自定义适配器创建了自定义布局,并获得了不错的结果但我无法做出单一选择,没有一个听众设置为ListView...:这是我的适配器:publicclassAlertListAdapterextendsBaseAdapter{ArrayListmData;ContextmContext;LayoutInflaterinflater;publicAlertListAdapter(ArrayListdata,Co